import React, { Component } from 'react';
import Lightbox from 'react-image-lightbox';
import {SingleInfo,InfoTitle,InfoImage2,InfoImage3,DateInfo} from '../common/Forminfo';
import {browserHistory,Link} from 'react-router';
import { connect } from 'react-redux';
import { ClearanceGet } from '../../Redux/Actions/clearanceAction';

class Clearance extends Component {
    constructor () {
        super();
        this.state = {
        }
    }

    componentWillMount(){
        const opt = {
            orderId:this.props.location.state.orderId,
            profileId:this.props.location.state.profileId
        }
        this.props.dispatch(ClearanceGet(this.props.authReducer.user.data.token,opt));
    }

    render(){
        const clearance = this.props.clearanceReducer.clearance.data;
        if(clearance){
          return(
            <div className="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
                <div className="row">
                    <ol className="breadcrumb">
                    <li><a href="#"><span className="glyphicon glyphicon-home"></span></a></li>
                    <li>报关详情</li>
                    </ol>
                </div>
                <div className="row">
                    <div className="col-lg-12">
                    <div className="panel panel-default">
                        <div className="panel-heading">
                            报关详情
                            <Link className="pull-right btn btn-primary" style={{marginTop:"6px"}} to={this.props.location.state.backurl}>返回</Link>
                            <Link to={{pathname:"/main/clearanceupdate",state:{backurl:this.props.location.state.backurl}}} className="pull-right btn btn-primary" style={{marginTop:"6px",marginRight:"15px"}}>编辑</Link>
                        </div>
                        <div className="panel-body">
                            <div className="form-horizontal">
                                <InfoTitle title="录号信息"/>
                                <SingleInfo label="车型" info={clearance.carType}/>
                                <SingleInfo label="车架号" info={clearance.carFrameNo}/>
                                <SingleInfo label="发动机号" info={clearance.engineNo}/>
                                <SingleInfo label="车辆颜色" info={clearance.carColor}/>
                                <SingleInfo label="轮胎尺寸" info={clearance.carTire}/>

                                <InfoTitle title="换单信息"/>
                                <DateInfo label="换单时间" info={clearance.changeBillTime}/>
                                <InfoTitle title="拆箱信息"/>
                                <InfoImage2 name="拆箱照片" src={clearance.openBoxUrl} />

                                <InfoTitle title="出税方式"/>
                                <SingleInfo label="是否出税" info={clearance.isSetTax}/>
                                <SingleInfo label="是否垫税" info={clearance.isPadTax}/>
                                <InfoImage3 name="打款回单" src={clearance.taxBillUrl} />
                                <SingleInfo label="是否立即出税" info={clearance.isPopTax}/>
                                <InfoImage3 name="税单照片" src={clearance.taxBillUrl} />

                                <InfoTitle title="海关放行信息"/>
                                <DateInfo label="放行时间" info={clearance.customsClearanceTime}/>

                                <InfoTitle title="整改信息"/>
                                <DateInfo label="整改时间" info={clearance.rectificationTime}/>

                                <InfoTitle title="车辆检测线"/>
                                <DateInfo label="预计时间" info={clearance.estimatedTime}/>
                                <DateInfo label="实际时间" info={clearance.actualTime}/>

                                <InfoTitle title="入库信息"/>
                                <SingleInfo label="车库名称" info={clearance.garageName}/>
                                <SingleInfo label="车库地址" info={clearance.garageAddress}/>
                                <SingleInfo label="看车人姓名" info={clearance.viewCarManName}/>
                                <SingleInfo label="看车人身份证" info={clearance.viewCarManIdentity}/>
                                <SingleInfo label="看车人联系方式" info={clearance.viewCarManPhone}/>
                                <SingleInfo label="提车人姓名" info={clearance.pickCarManName}/>
                                <SingleInfo label="提车人身份证" info={clearance.pickCarIdentity}/>
                                <SingleInfo label="提车人联系方式" info={clearance.pickCarManPhone}/>
                                <DateInfo label="预约看车时间" info={clearance.appointmentViewCarTime}/>
                                <SingleInfo label="是否当日提车" info={clearance.isPickCarDenges}/>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>	
            </div>
            )
        }else{
            return <div></div>
        }
    }
}

export default connect((state) => {
    const { authReducer,clearanceReducer } = state;
    return {
        authReducer,clearanceReducer
    }
})(Clearance);